            ------------------------------ Win Tutorial -----------------------------
                               Created by: Onizuka
			       Email: Shadyx10@aol.com
			       Create Date: 6/3/05
			       Version: 1.0
                               

What is this going to show me?
	This is going to show you how to send commands over a winsock connection to another computer
What this is made of?
	This is actually 2 programs, Client, and Server. Both are very important.
Why would I need this?
	That is up to you. From here, you can go very far with this. Design what ever you desire.

WARNING!!!
	This material in some cases can be treated as malicious! Some simple trojans follow this path,
and this is not intended for that purpose. I am not responisble for any damage or federal trouble that
you may get into using this program. Please, it's only educational.

Lets get started!

Ok, first lets make the client. This is what will control everything the server does. So open up
Visual Basic and select "Standard EXE". Now we are ready.

A little overview of Client and Server.
	Ok Client in this case is like boss over the server. What ever the client says to do, the
server will respond with the requested command. We use a Winsock to connect the two computers. Once
the server is started, the client is able to connect and start commanding. This simple method can be
used for various things.

Start the client!
	Alright first we will need a Winsock control. Go to File > Components (or Ctrl+T), and from 
there scroll down until you see "Microsoft Winsock 6.0", or what ever it might be called. Check the
box and click apply. The Winsock should appear on your toolbar. Select it and create a Winsock on the
form and place it anywhere. Make sure to name this Winsock "Winsock" instead of "Winsock1".
Ok now lets set up the Winsock connectiong. Add 1 command button to your
project, and name it cmdConnect. Now double click on your button and insert this code into the code
section:

Private Sub cmdConnect_Click()
Winsock.RemoteHost = "127.0.0.1"  ' this is the Ip of the server 127.0.0.1 and back to your own comp
Winsock.RemotePort = 15151  ' this is the port it must be the same as the server
Winsock.Connect  ' connect!
End Sub

When the server is on, this command will connect to it. Now how do we know if we really connected?
Well lets fix that and have a message box appear and tell us! Place this code anywhere in your code
box:

Private Sub winsock_connect() 'What ever is below will happen when the connection is set
MsgBox "We are connected" 'Yay we are connected!
End Sub

Ok, before we continue make sure you have the command "Option Explicit" at the very top of your code 
box. It should be in the "General" area. Now save your project somewhere and open a new one. Make sure
it is "Standard EXE". Ok now it is time for the server! Lets start by placing a Winsock control the 
same way we did last time. Name theWinsock "Winsock" instead of the defualt "Winsock1". Ok lets make
a simple command that will make a
message box appear when the client says so. Put this code anywhere in your code box:

Private Sub winsock_DataArrival(ByVal bytesTotal As Long)
Dim incommingData As String 'this variable will be the storage for the data we recieve
Winsock.GetData incommingData ' this will place the data we recieved into the variable
If incommingData = "Msgbox" Then 'If the data sent from the client was "Msgbox" then do the following
	Msgbox "It worked!" 'If everything worked correctly a Msgbox will appear saying "It Worked"
	Exit Sub 'This will exit the sub, important later on for more coding
End If
End Sub

Ok, now we when the Client sends the correct data a message box will appear. Now what are we missing?
No duh! We have no connection! Good job if you noticed that. Lets setup our connection now. Place
this code anywhere on your code box:

Private Sub Form_Load()
Winsock.LocalPort = 15151 'Opens the port on your machine
Winsock.Listen ' This starts your connection!

End Sub

Private Sub Winsock_ConnectionRequest(ByVal requestID As Long)
Winsock.Close 'this closes it and makes it ready for any incomming connection
Winsock.Accept requestID 'accepts the incomming connection

End Sub

There! Now when the server is loaded it will start listening for a connection. Then when the client
attempts to connect it will accept, and WaLa! We have a connection. Ok, now it's time to get the 
message box working. Save your project and go back to your Client project. Ok lets make the command
for the message box to appear. Make a command button on your form. Name it "cmdMsg". Double click on
it and put the following code in the code box:

Private Sub cmdMsg_Click()
Dim Data1 As String 'Makes the variable the data will be carried in
Data1 = "Msgbox" 'Place the data "Msgbox" into the variable
Winsock.SendData Data1 'Sends the data for the server to recieve!
End Sub

There, this should make the message box appear. Ok, this is the basic form of it. Open your Server 
project in another window (If you already havn't). Now load the Server by pressing the triangle
shaped button on the top bar. Now go back to your Client project and run it as well. Ok now that both
are open press the connect button on your Client project. A message box saying "You are connected",
should appear. Now press your other command button and WaLa a message box saying "It Worked" should
appear on your screen. There we have it, we have sent a command over a Winsock connection. Very simple
and useful!

Now you should go get a friend to help you test it next. Make the server EXE and send your friend the
file. Now tell him/her to run the Server.exe. Now run your Client program. Hit the connect button,
then the command button that makes the message box appear. WaLa, the message box should appear on
your friends screen.

I really hoped you enjoyed this short tutorial, and please use it for good only! If something goes
wrong or you have a question please contact me at Shadyx10@aol.com. Or AliasXNeo@hotmail.com.

Also if this helped you, or you have some comments to add on, please email me as well.


Also Included in this tutorial:
	There is 2 folders also in this tutorial. One is Client, and the other Server. They both
are an example of what you just did. Although they have alot higher level coding in them, they work
just the same way as the one we created. You can check out the coding, or run the EXE's and see how
they work. Just dont steal the coding!

Also Note:
	Some of the coding in the included files are not mine. As I do not know who the author of it
is I cannot give the credit. Just note that, some of it is not mine.

Hope you enjoyed this tutorial, more versions will be coming out soon. As for now,

			~	Onizuka out!	~




